﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UtilityLibrary.Paramater;
using System.Configuration;
using System.Net;
using UtilityLibrary.Http;

namespace SYHParamter
{
    public abstract class DomainRequest<T> : RequestParamater<T>
    {
        public override string Domain
        {
            get { return ConfigurationManager.AppSettings["SyhDomain"]; }
        }

        public override T GetResponseParamater()
        {
            //创建请求对象
            HttpWebRequest request = DefaultRequest.FromString(Action);
            //创建请求处理对象
            HttpClient client = new HttpClient(DefaultEncoding);
            //执行请求，获取响应结果
            JsonContext jsonContext = client.PostJsonContext(request, Items);
            //根据响应结果json串，生成响应结果参数实例
            return jsonContext.ToObject<T>();
        }
    }
}
